<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用instanceof检测对象实现</title>
</head>
<body>
    <script>
        // function User(){}
        // function Admin(){}
        // Admin.prototype = Object.create(User.prototype);
        // let hd = new Admin();
        // // instanceof 判断Admin.prototype是否在hd的原型链上
        // console.log(hd instanceof Admin);
        // console.log(hd instanceof User);
        // console.log(hd.__proto__ == Admin.prototype);
        // console.log(hd.__proto__.__proto__ == Admin.prototype.__proto__);
        // console.log(Admin.__proto__.__proto__.__proto__);


        // function checkPrototype(obj,constructor){
        //     if(!obj.__proto__) return false;
        //     if(obj.__proto__ == constructor.prototype) return true;
        //     return checkPrototype(obj.__proto__,constructor);
        // }

        // console.log(checkPrototype(hd,User));


        class User{}
        class Admin extends User{}
        let hd = new Admin();
        console.log(hd instanceof User);
    </script>
</body>
</html>